<?php
$this->title = "会员列表";
?>
<div class="main">
	<div class="header">会员列表</div>
	<div class="oper">
		<a href="<?=ROOT_URL?>user/create" class='btn btn-primary'>添加用户</a>
	</div>
	<table class="mytable table table-bordered table-striped table-hover" id="user">
		<thead>
			<tr>
				<th>用户名</th>
				<th>性别</th>
				<th>工作单位</th>
				<th>部门</th>
				<th>职务</th>
				<th>邮箱</th>
				<th>联系方式</th>
				<th>真实姓名</th>
				<th>级别</th>
				<th>所属会员组</th>
				<th width="80">操作</th>
			</tr>
		</thead>
		<tbody>
			<?php
		 	//var_dump($users);
		 	foreach ($users as $key => $value) {
		 		echo "<tr>";
		 		echo "<td>".$value['username']."</td>";
		 		echo "<td>".$value['sex']."</td>";
		 		echo "<td>".$value['company']."</td>";
		 		echo "<td>".$value['department']."</td>";
		 		echo "<td>".$value['job']."</td>";
		 		echo "<td>".$value['email']."</td>";
		 		echo "<td>".$value['cellphone']."</td>";
		 		echo "<td>".$value['truename']."</td>";
		 		switch ($value['usertype']) {
		 			case '1':
		 				echo "<td>普通用户</td>";
		 				break;
		 			case '2':
					    echo "<td>文章编辑员</td>";
						break;
					case '3':
						echo "<td>文章审核员</td>";
						break;
					case '4':
						echo "<td>超级管理员</td>";
						break;
					
		 			default:
		 				echo "<td></td>";
		 				break;
		 		}
		 		echo "<td>".$value['groups']."</td>";
		 		echo "<td><a href='".ROOT_URL."user/update&id=".$value['id']."'>更改</a><br><a href=\"javascript:del('".$value['id']."','".$value['username']."');\">删除</a></td>";
		 		echo "</tr>";
		 	}
		 	?>
		</tbody>
	</table>
 	
    <script type="text/javascript">
    	$("#user").dataTable({
            //"lengthChange": false,
            "dom": 't<"col-sm-5"i>p',
            "ordering": false,
            "sPaginationType": "full_numbers",
            "oLanguage": {
                "sInfo": "共_TOTAL_条数据，展示_START_到_END_条数据",
                "sInfoEmpty": "无数据",
                "sInfoFiltered": "(从_MAX_条数据中的查询)",
                "sLengthMenu": "每页显示 _MENU_ 条数据",
                "sSearch":  "查找 _INPUT_ ",
                "sZeroRecords": " ",
                "oPaginate":{
                    "sPrevious":"上一页",
                    "sNext":"下一页",
                    "sLast":"尾页",
                    "sFirst":"首页"
                },
            },
            "iDisplayLength":10,
            // "aaSorting": [[3,'desc']]                  
        });

        function del(id,username)
        {
        	if(confirm("确定要删除用户 "+username+" 吗")){
        		$.post("<?=ROOT_URL?>user/delete",{id:id},function(){
        			window.location.reload();
        		});
        	}
        }
    </script>
<div>
